package com.examination.client.controller;


import com.examination.client.domian.dto.BuyMessageDTO;
import com.examination.client.domian.dto.ScanSendMessageDTO;
import com.examination.client.domian.dto.SendMessageDTO;
import com.examination.client.domian.dto.SiteMessageDTO;
import com.examination.client.domian.vo.MessageCountVO;
import com.examination.client.service.MessageService;
import com.examination.client.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author xiaodong
 * @since 2021-10-20
 */
@RestController
@RequestMapping("/message")
@Api(tags = "消息相关")
@CrossOrigin(origins = "*")
public class MessageController {
    @Resource
    private MessageService messageService;

    @ApiOperation("发送短信")
    @PostMapping("/send")
    public Result<Boolean> send(@RequestBody @Validated SendMessageDTO sendMessageDTO){
        return Result.success(messageService.send(sendMessageDTO));
    }

    @ApiOperation("查询可用短信条数")
    @PostMapping("/available/num")
    public Result<Integer> availableNum(){
        return Result.success(messageService.availableNum());
    }

    @ApiOperation("扫码发送短信")
    @PostMapping("/scan/send")
    public Result<Boolean> scanSend(@RequestBody @Validated ScanSendMessageDTO scanSendMessageDTO){
        return Result.success(messageService.scanSend(scanSendMessageDTO));
    }

    @ApiOperation("短信数量")
    @GetMapping("/count")
    public Result<MessageCountVO> count(){
        return Result.success(messageService.count());
    }

    @ApiOperation("保存短信数量信息")
    @PostMapping("/save")
    public Result<Boolean> save(@RequestBody @Validated SiteMessageDTO siteMessageDTO){
        return Result.success(messageService.save(siteMessageDTO));
    }



}
